import { reqGetAllPos, reqGetRecycleDevices, reqGetBrandByRecycleType, reqGetTypesByRecycleTypeAndModel, reqGetCheckMarks } from '@/api/check.js'
export default {
  name: 'hand_update_common',
  data () {
    return {
      pos: null,
      brands: null,
      models: null,
      devices: null,
      brands: null,
      models: null,
      marks: null
    }
  },
  mounted () { },
  methods: {
    // 获取所有PO
    async getPos () {
      const res = await reqGetAllPos()
      this.pos = res.data.data
    },
    // 获取所有设备类型
    async getDevices () {
      const res = await reqGetRecycleDevices()
      if (res.data.code == 0) {
        this.devices = res.data.data
      }
    },
    // 根据设备类型获取所有品牌
    async getBrands (id) {
      const res = await reqGetBrandByRecycleType(id)
      if (res.data.code == 0) {
        this.brands = res.data.data
      }
    },
    // 获取所有型号
    async getModels (typeId, brandId) {
      const res = await reqGetTypesByRecycleTypeAndModel(typeId, brandId)
      if (res.data.code == 0) {
        this.models = res.data.data
      }
    },
    // 根据名称获取id
    getIdByDeviceName (name) {
      return this.devices.find((item) => {
        return item.typeName == name
      }).typeId
    },
    // 获取所有备注
    async getMarks (id) {
      const res = await reqGetCheckMarks(id)
      if (res.data.code == 0) {
        this.marks = res.data.data
      }
    }

  }
}
